package com.ny.Map;

import java.util.List;

public class Testlist {
    public void addEmp(List<Aot> list, Aot aot) {
        if (aot != null) {
            list.add(aot);
        }
    }

    public void findAllEmp(List<Aot> list) {
        if (list.isEmpty()) {
            System.out.println("No employees found.");
            return;
        }
        for (Aot aot : list) {
            System.out.println(aot);
        }
    }

    public Aot findEmpByName(List<Aot> list, String name) {
        for (Aot aot : list) {
            if (name.equals(aot.getName())) {
                return aot;
            }
        }
        return null;
    }

    public boolean deleteEmpByNumber(List<Aot> list, String num) {
        for (int i = 0; i < list.size(); i++) {
            if (num.equals(list.get(i).getNum())) {
                list.remove(i);
                return true;
            }
        }
        return false;
    }

    public Aot findEmpByNumber(List<Aot> list, String number) {
        for (Aot aot : list) {
            if (number.equals(aot.getNumber())) {
                return aot;
            }
        }
        return null;
    }

    public boolean updateEmpAge(List<Aot> list, Aot aot) {
        for (int i = 0; i < list.size(); i++) {
            if (aot.getNumber().equals(list.get(i).getNumber())) {
                list.set(i, aot);
                return true;
            }
        }
        return false;
    }
}